package net.xiduth.game.player.dialogues;

import net.xiduth.game.player.Skills;

public class RankShop extends Dialogue {

	private int npcId;


	@Override
	public void start() {
		npcId = 15558;
		sendNPCDialogue(npcId, CALM_TALKING, "You currently have <col=ff0000>" + player.rankpoints + "</col> Rank Points.");
		stage = -1;
	}

	@Override
	public void run(int interfaceId, int componentId) {
		if (stage == -1) {
			sendOptionsDialogue("Select an Option", "How many points do I have?", "How do I get points?", "I would like to exchange my points.");
			stage = 1;
		} else if (stage == 1) {
			if (componentId == OPTION_1)
			sendNPCDialogue(npcId, CALM_TALKING, "You currently have <col=ff0000>" + player.rankpoints + "</col> Rank Points.");
			else if (componentId == OPTION_2)
			sendNPCDialogue(npcId, CALM_TALKING, "You can gain points by Skilling or killing training monsters.");
			else if (componentId == OPTION_3)
			sendOptionsDialogue("Select a Reward", "Titles", "Outfits", "Experience");
			stage = 2;
		} else if (stage == 2) {
			if (componentId == OPTION_1) { //Titles
				sendOptionsDialogue("Titles", "Corporal", "Specialist", "Sergeant", "Lieutenant", "Colonel");
				stage = 3;
			}else if (componentId == OPTION_2) {
				sendOptionsDialogue("Outfits", "Lieutenant Outfit", "Coming Soon");
				stage = 4;
			}else if (componentId == OPTION_3) {
				sendOptionsDialogue("Experience", "Dungeoneering", "Construction", "Farming");
				stage = 5;
			}
		} else if (stage == 3) { //Titles
			if (componentId == OPTION_1) {
				if (player.rankpoints >= 100 && player.corporal == true) {
					player.getAppearence().setTitle(59059);
					player.sm("Your current title is now <col=FF0000>Corporal</col>");
					player.getInterfaceManager().closeChatBoxInterface();
					player.rankpoints -= 100;
				}
				if (player.rankpoints <= 100 && player.corporal == false) {
				sendNPCDialogue(npcId, 9827, "You need 100 points to buy this and must be a Coporal." );
				stage = 55;
				}
			} else if (componentId == OPTION_2)
				if (player.rankpoints >= 250 && player.specialist == true) {
					player.getAppearence().setTitle(59058);
					player.sm("Your current title is now <col=FF0000>Specialist</col>");
					player.getInterfaceManager().closeChatBoxInterface();
					player.rankpoints -= 250;
				}
				if (player.rankpoints <= 250 && player.specialist == false) {
				sendNPCDialogue(npcId, 9827, "You need 250 points to buy this and must be a Specialist." );
				stage = 55;
				}
			else if (componentId == OPTION_3)
				if (player.rankpoints >= 350 && player.sergeant == true) {
					player.getAppearence().setTitle(59057);
					player.sm("Your current title is now <col=FF0000>Sergeant</col>");
					player.getInterfaceManager().closeChatBoxInterface();
					player.rankpoints -= 350;
				}
				if (player.rankpoints <= 350 && player.sergeant == false) {
				sendNPCDialogue(npcId, 9827, "You need 350 points to buy this and must be a Sergeant." );
				stage = 55;
				}
			else if (componentId == OPTION_4)
				if (player.rankpoints >= 500 && player.lieutenant == true) {
					player.getAppearence().setTitle(59056);
					player.sm("Your current title is now <col=FF0000>Lieutenant</col>");
					player.getInterfaceManager().closeChatBoxInterface();
					player.rankpoints -= 500;
				}
				if (player.rankpoints <= 500 && player.lieutenant == false) {
				sendNPCDialogue(npcId, 9827, "You need 500 points to buy this and must be a Lieutenant." );
				stage = 55;
				}
				else if (componentId == OPTION_5)
					if (player.rankpoints >= 2500 && player.colonel == true) {
						player.getAppearence().setTitle(59055);
						player.sm("Your current title is now <col=FF0000>Colonel</col>");
						player.getInterfaceManager().closeChatBoxInterface();
						player.rankpoints -= 2500;
					}
					if (player.rankpoints <= 500 && player.colonel == false) {
					sendNPCDialogue(npcId, 9827, "You need 2500 points to buy this and must be a Colonel." );
					stage = 55;
					}
		} else if (stage == 4) {
			if (componentId == OPTION_1) {
				if (player.rankpoints >= 700 && player.lieutenant == true) {
					player.sm("You are rewarded a outfit in your bank.");
					player.getBank().addItem(15021, 1, true);
					player.getBank().addItem(15022, 1, true);
					player.getBank().addItem(15023, 1, true);
					player.getBank().addItem(15024, 1, true);
					player.getBank().addItem(15025, 1, true);
					player.getBank().addItem(15026, 1, true);
					player.getInterfaceManager().closeChatBoxInterface();
					player.rankpoints -= 700;
				}
				if (player.rankpoints <= 750 && player.lieutenant == false) {
				sendNPCDialogue(npcId, 9827, "You need 700 points to buy this and must be a Lieutenant." );
				stage = 55;
				}
			}
		} else if (stage == 5) {
			if (componentId == OPTION_1) {
				if (player.rankpoints >= 100) {
					player.sm("You are where awarded Dungeoneering experience.");
					player.getSkills().addXp(Skills.DUNGEONEERING, 1800);
					player.getInterfaceManager().closeChatBoxInterface();
					player.rankpoints -= 100;
				}
					if (player.rankpoints <= 100) {
				sendNPCDialogue(npcId, 9827, "You need 100 points to buy this." );
				stage = 55;
				}
			} else if (componentId == OPTION_2)
				if (player.rankpoints >= 100) {
					player.sm("You are where awarded Construction experience.");
					player.getSkills().addXp(Skills.CONSTRUCTION, 1800);
					player.getInterfaceManager().closeChatBoxInterface();
					player.rankpoints -= 100;
				}
					if (player.rankpoints <= 100) {
				sendNPCDialogue(npcId, 9827, "You need 100 points to buy this." );
				stage = 55;
				}
			else if (componentId == OPTION_3)
				if (player.rankpoints >= 100) {
					player.sm("You are where awarded Farming experience.");
					player.getSkills().addXp(Skills.FARMING, 1800);
					player.getInterfaceManager().closeChatBoxInterface();
					player.rankpoints -= 100;
				}
					if (player.rankpoints <= 100) {
				sendNPCDialogue(npcId, 9827, "You need 100 points to buy this." );
				stage = 55;
				}
		}
	}

	@Override
	public void finish() {

	}
}
